import React, { Component } from 'react';
import { ajax, toast} from 'nc-lightapp-front';

class BatchFileUploadModal extends Component {
    constructor(props) {
        super(props);
    }

    //导入
    upload(v) {
        window.hh = this
        if (!v) {
            return;
        }
        let formData = new FormData();
        let dome = document.querySelector('#fileInfo')
        // formData.append('imgfile', dome.files);
        //加参数
        for(var i = 0; i < dome.files.length; i ++){
            formData.append('attachment', dome.files[i]);
        }
        
        // headers['Content-Type'] == 'multipart/form-data'
        ajax({
            url: '/nccloud/hrhi/pub/batchFileUpload.do',
            data: formData,
            headers:{'Content-Type': 'multipart/form-data'},
            success: (res) => {
                toast({content: '操作成功',color:'success'});
            }
        })
    }

    render () {
        return(
            <input multiple="multiple" style={{display: 'none'}} type='file' id='fileInfo' onChange={(v) => {this.upload(v)}}/>
        )
        
    }

}

export default BatchFileUploadModal;